// pages/medicine/pages/meetingDetails/meetingDetails.js
var app = getApp()
var city = require('../../../../utils/city.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    navigation: ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'],
    list: [],
    topID: 'A',
    toView: 'red',
    scrollTop: 100,
    current: {
      initial: '当前/历史',
      cityInfo: []
    },
    value: '输入城市名称搜索'
  },

  // 导航
  sure: function(e) {
    let a = e.target.dataset.id;
    this.setData({
      topID: a
    })
    console.log(this.data.topID)
  },
  //搜索内容
  searchBox: function(e) {
    let val = e.detail.value;
    console.log(val)
  },
  //确定所在城市
  OK: function(e) {
    let city = e.currentTarget.dataset.city;
    //
    app.util.request({
      'url': 'entry/wxapp/Getcitywd',
      data: {
        city: city
      },
      success: function(res) {
        let pages = getCurrentPages();
        let currPage = pages[pages.length - 1]; //当前页面
        let prevPage = pages[pages.length - 2]; //上一个页面
        prevPage.setData({
          position: city,
          latitude: res.data.lat,
          longitude: res.data.lng,
          types: 1
        })
        wx.navigateBack({
          delta: prevPage
        })
      }
    })

  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    let that = this;
    if (options.position) {
      var position = options.position
      that.setData({
        cityInfo: position
      })
    }
    wx.getSystemInfo({
      success: function(res) {
        let a = res.screenHeight;
        let h = a / 18;
        let c = Math.floor(h)
        that.setData({
          Heights: c,
          Height: c * 15
        })
      }
    })
    wx.getLocation({
      type: 'wgs84', //默认为 wgs84 返回 gps 坐标，gcj02 返回可用于 wx.openLocation 的坐标 
      success: function(res) {
        let longitude = res.longitude;
        let latitude = res.latitude;
        console.log(longitude)
        console.log(latitude)
      }
    })
    let searchLetter = city.searchLetter;
    let cityList = city.cityList();
    let current = {
      initial: '当前/历史',
      cityInfo: [{
        city: '太原'
      }]
    }
    that.setData({
      list: cityList,
      navigation: searchLetter
    })
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function() {

  }
})